#include "Common.hpp"

int main()
{
    std::string query_string;
    GetQueryString(query_string);
    //以&为分隔符将两个操作数分开
    std::string parameter1,parameter2;
    CurString(query_string,parameter1,parameter2,"&");
    //以=为分隔符分别获取两个操作数的值
    std::string key1,value1,key2,value2;
    CurString(parameter1,key1,value1,"=");
    CurString(parameter2,key2,value2,"=");


    //处理数据
    int x = atoi(value1.c_str());
    int y = atoi(value2.c_str());
    std::cout<<"<html>";
    std::cout<<"<head><meta charset=\"UTF-8\"></head>";
    std::cout<<"<body>";
    std::cout<<"<h3>"<<x<<" + "<<y<<" = "<<x+y<<"</h3>";
    std::cout<<"<h3>"<<x<<" - "<<y<<" = "<<x-y<<"</h3>";
    std::cout<<"<h3>"<<x<<" * "<<y<<" = "<<x*y<<"</h3>";
    std::cout<<"<h3>"<<x<<" / "<<y<<" = "<<x/y<<"</h3>"; //除0后cgi程序崩溃，属于异常退出
    std::cout<<"</body>";
    std::cout<<"</html>";

    return 0;
}